//
//  HZProductTextImageDetailFootView.m
//  app
//
//  Created by 刘华舟 on 15/6/4.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZProductTextImageDetailFootView.h"

static const NSInteger kImageViewWidth = 80;
static const NSInteger kLabelHeight = 60;
static const NSInteger kLabelWidth = 160;
static const NSInteger kBottomBackViewHeight = 160;
static const NSInteger kMainViewHeight = kLabelHeight + kSizeMallViewMargin/2 + kBottomBackViewHeight;


@implementation HZProductTextImageDetailFootView

- (void)drawRect:(CGRect)rect{
    [self drawHorizonLineLeft:0 right:0 at:[self.ubo ph:UP(1)]];
    [self drawHorizonLineLeft:0 right:0 at:[self.ubo uh:kLabelHeight+kSizeMallViewMargin/2 ph:UP(-1)]];
}


- (instancetype)initWithFrame:(CGRect)frame{
    frame = CGRectOf(frame.origin, [UBO_SCREEN fw:UB_WIDTH uh:kMainViewHeight]);
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HZ_WHITE_COLOR;
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kSizeMallViewMargin fy:UB_TOP uy:kSizeMallViewMargin/4],
                                                                      [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.font = kHZFont_Content_S;
        titleLabel.textColor = HZ_MALL_TEXT_S_LIGHTGRAY_COLOR;
        titleLabel.text = @"配送流程";
        [self addSubview:titleLabel];
        
        UILabel *moreLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_RIGHT ux:-2*kSizeMallViewMargin-kLabelWidth fy:UB_TOP uy:kSizeMallViewMargin/4],
                                                                     [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        moreLabel.textAlignment = NSTextAlignmentRight;
        moreLabel.font = kHZFont_Content_S;
        moreLabel.textColor = HZ_MALL_MAIN_THEME_M_BLUE;
        moreLabel.text = @"查看更多";
        [self addSubview:moreLabel];
        
        UIButton *seeMoreBtn = [[UIButton alloc] initWithFrame:CGRectOf([self.ubo fx:UB_RIGHT ux:-kSizeMallViewMargin-kLabelWidth fy:UB_TOP uy:kSizeMallViewMargin/4],
                                                                        [self.ubo uw:kLabelWidth uh:kLabelHeight])];

        [seeMoreBtn setImage:[UIImage imageNamed:kImageArrowRightBlue] forState:UIControlStateNormal];
       
        
        seeMoreBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        seeMoreBtn.titleLabel.font = JKAppGlobleFontContentText;
        
        [seeMoreBtn addTarget:self action:@selector(seeMoreBtnOnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:seeMoreBtn];
        
        UIView *bottomBackView = [[UIView alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT fy:UB_BOTTOM uy:-kBottomBackViewHeight],
                                                                        [self.ubo fw:UB_WIDTH uh:kBottomBackViewHeight])];
        bottomBackView.backgroundColor = HZ_WHITE_COLOR;
        
        UIImageView *phoneImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:UB_1_2*UB_1_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                  [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight])];
        [phoneImageView setImage:[UIImage imageNamed:kImageDeliveryCellphone]];
        phoneImageView.contentMode = UIViewContentModeBottom;
        [bottomBackView addSubview:phoneImageView];
        
        UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectOf([phoneImageView.ufo fx:UB_CENTER ux:-kLabelWidth/2 fy:UB_BOTTOM],
                                                                      [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        phoneLabel.textAlignment = NSTextAlignmentCenter;
        phoneLabel.font = JKAppGlobleFontMinTagText;
        phoneLabel.textColor = HZ_MALL_TEXT_L_LIGHTGRAY_COLOR;
        phoneLabel.text = @"订单提交";
        [bottomBackView addSubview:phoneLabel];
        
        UIImageView *LeftImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:UB_1_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                  [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight/2])];
        [LeftImageView setImage:[UIImage imageNamed:kImageDeliveryLongArrow]];
        LeftImageView.contentMode = UIViewContentModeCenter;
        [bottomBackView addSubview:LeftImageView];
        
        UIImageView *cardImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:UB_1_2*UB_3_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                  [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight])];
        [cardImageView setImage:[UIImage imageNamed:kImageDeliveryCard]];
        cardImageView.contentMode = UIViewContentModeBottom;
        [bottomBackView addSubview:cardImageView];
        
        UILabel *cardLabel = [[UILabel alloc] initWithFrame:CGRectOf([cardImageView.ufo fx:UB_CENTER ux:-kLabelWidth/2 fy:UB_BOTTOM],
                                                                      [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        cardLabel.textAlignment = NSTextAlignmentCenter;
        cardLabel.font = JKAppGlobleFontMinTagText;
        cardLabel.textColor = HZ_MALL_TEXT_L_LIGHTGRAY_COLOR;
        cardLabel.text = @"付款成功";
        [bottomBackView addSubview:cardLabel];
        
        UIImageView *centerImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:UB_1_2 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                 [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight/2])];
        [centerImageView setImage:[UIImage imageNamed:kImageDeliveryLongArrow]];
        centerImageView.contentMode = UIViewContentModeCenter;
        [bottomBackView addSubview:centerImageView];
        
        UIImageView *carImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:5*UB_1_2*UB_1_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                  [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight])];
        [carImageView setImage:[UIImage imageNamed:kImageDeliveryCar]];
        carImageView.contentMode = UIViewContentModeBottom;
        [bottomBackView addSubview:carImageView];
        
        UILabel *carLabel = [[UILabel alloc] initWithFrame:CGRectOf([carImageView.ufo fx:UB_CENTER ux:-kLabelWidth/2 fy:UB_BOTTOM],
                                                                      [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        carLabel.textAlignment = NSTextAlignmentCenter;
        carLabel.font = JKAppGlobleFontMinTagText;
        carLabel.textColor = HZ_MALL_TEXT_L_LIGHTGRAY_COLOR;
        carLabel.text = @"商家发货";
        [bottomBackView addSubview:carLabel];
        
        UIImageView *rightImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:UB_3_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                 [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight/2])];
        [rightImageView setImage:[UIImage imageNamed:kImageDeliveryLongArrow]];
        rightImageView.contentMode = UIViewContentModeCenter;
        [bottomBackView addSubview:rightImageView];
        
        UIImageView *reciverImageView = [[UIImageView alloc] initWithFrame:CGRectOf([bottomBackView.ubo fx:7*UB_1_2*UB_1_4 ux:-kImageViewWidth/2 fy:UB_TOP],
                                                                                  [bottomBackView.ubo uw:kImageViewWidth fh:UB_HEIGHT uh:-kLabelHeight])];
        [reciverImageView setImage:[UIImage imageNamed:kImageDeliveryReciver]];
        reciverImageView.contentMode = UIViewContentModeBottom;
        [bottomBackView addSubview:reciverImageView];
        
        UILabel *reciverLabel = [[UILabel alloc] initWithFrame:CGRectOf([reciverImageView.ufo fx:UB_CENTER ux:-kLabelWidth/2 fy:UB_BOTTOM],
                                                                      [self.ubo uw:kLabelWidth uh:kLabelHeight])];
        reciverLabel.textAlignment = NSTextAlignmentCenter;
        reciverLabel.font = JKAppGlobleFontMinTagText;
        reciverLabel.textColor = HZ_MALL_TEXT_L_LIGHTGRAY_COLOR;
        reciverLabel.text = @"确认收货";
        [bottomBackView addSubview:reciverLabel];
        
        [self addSubview:bottomBackView];
    }
    return self;
}

- (void)seeMoreBtnOnClick{
    if (self.targetCallerSeeDeliveryInfo) {
        [self.targetCallerSeeDeliveryInfo call];
    }
}

@end
